package Demo;

import java.util.Arrays;
import java.util.Comparator;


/**
 * Created with IntelliJ IDEA.
 * User: wenxiwen
 * Date: 2022/4/10
 * Time: 19:28
 * Description: No Description
 */
class Money {
    public int money;

}
class Student implements Comparable<Student>{
    public String name;
    public int age;
    public int score;

    public Student(String name, int age, int score) {
        this.name = name;
        this.age = age;
        this.score = score;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", score='" + score + '\'' +
                '}';
    }



    public void fun() {
        System.out.println("这是一个成员方法");
    }

    @Override
    public int compareTo(Student o) {
        return this.age - o.age;
    }
}

class Cmp implements Comparator<Student> {

    @Override
    public int compare(Student o1, Student o2) {
        return o2.age - o1.age;
    }
}
public class TestDemo extends Deme1.TestDemo {

    /*public void sleep() {
        super.scare1 = 20;
    }*/

    public static void main3(String[] args) {
        Deme1.TestDemo test = new Deme1.TestDemo();


    }
    public static void main2(String[] args) {
        Student student = new Student("zhangsan",18,98);
        Student student1 = new Student("lisi",20,66);
        Student student2 = new Student("wangwu",21,88);
        if(student.compareTo(student1) > 0) {
            System.out.println("true");
        } else if(student.compareTo(student1) < 0) {
            System.out.println("false");
        } else {
            System.out.println("相等");
        }
    }
    public static void main1(String[] args) {
        Student[] student = new Student[3];
        student[0] = new Student("zhangsan",18,98);
        student[1] = new Student("lisi",20,66);
        student[2] = new Student("wangwu",21,88);

        Cmp cmp = new Cmp();
        Arrays.sort(student,cmp);
        System.out.println(Arrays.toString(student));
    }
}